#pragma once

#define WIN32_LEAN_AND_MEAN

#include <wtypes.h>
#include <string>
#include <atlstr.h>
#include <tlhelp32.h>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <tchar.h>
#include <psapi.h>

typedef LONG(NTAPI *_NtSuspendProcess)(IN HANDLE ProcessHandle);
typedef LONG(NTAPI *_NtResumeProcess)(IN HANDLE ProcessHandle);

using namespace std;

class CProcess
{
public:
	CProcess() { EnableDebugPrivilege(); }

	// Select process
	BOOL open(DWORD pid);
	BOOL open(string szProcessName);
	BOOL open(HANDLE hProcess);

	// Close Handle
	BOOL close() { CloseHandle(m_hProcess); m_hProcess = NULL; }

	// Terminate Process
	BOOL terminate();

	// Suspend/Resume
	BOOL suspend();
	BOOL resume();

	// Inject/Free
	BOOL inject(string szDllName);
	BOOL free(string szDllName);

	// Get Process Info
	int getPid() { return m_nPid; }
	string getProcessName() { return m_szProcecssName; }
	PROCESS_MEMORY_COUNTERS getProcessMemoryInfo();

	~CProcess() { CloseHandle(m_hProcess); m_hProcess = NULL; }
protected:
	HANDLE m_hProcess = NULL;
	DWORD m_nPid = 0;
	string m_szProcecssName = "";

	_NtSuspendProcess NtSuspendProcess = 0;
	_NtResumeProcess NtResumeProcess = 0;
private:
	BOOL EnableDebugPrivilege();
};